package com.study.java8;

/**
 * @author ysy
 * @version 1.0
 * @Title: LamdaTest
 * @Note <b>ProjectName:</b> cusc-venus
 * <br><b>PackageName:</b> com.cusc.venus.acc.center.util
 * <br><b>ClassName:</b>
 * <br><b>Date:</b>
 */
public class lambdaTest1 {

    public static void main(String[] args) {
        IPerson student1 = new Student1();
        student1.work();

        IPerson student2 = new Student2();
        student2.work();

        // 3. 局部内部类
        class Student3 implements IPerson{
            @Override
            public void work() {
                System.out.println("Student3");
            }
        }
        IPerson student3 = new Student3();
        student3.work();

        // 4. 匿名内部类
        IPerson student4 = new IPerson(){
            @Override
            public void work() {
                System.out.println("Student4");
            }
        };
        student4.work();

        // 5. lamda表达式
        IPerson student5 = () ->{
            System.out.println("Student5");
        };
        student5.work();
        student5 = () -> System.out.println("Student5");
        student5.work();
    }

    // 2. 静态内部类
    static class Student2 implements IPerson{
        @Override
        public void work() {
            System.out.println("Student2");
        }
    }

    // 1. 内部类
    static class Student1 implements IPerson{
        @Override
        public void work() {
            System.out.println("Student1");
        }
    }

    // 定义一个接口
    interface IPerson{
        void work();
    }
}


